Private WithEvents m_ActiveViewChanged As Map
Private m_runYet As Boolean

Private Function MxDocument_ActiveViewChanged() As Boolean

'*************************************************************************
'This code will switch off the Layout toolbar when switching to Data view.
'Copy this code to the Normal.mxt -> ThisDocument to make this the default
'behaviour.
'
'History: Original coding 30 January 2004 - Stephen Lead
'
'Please report any problems or comments via the ArcScripts page

  Dim pMxDoc As IMxDocument
  Set pMxDoc = ThisDocument
  Dim pActiveView As IActiveView
  Set pActiveView = pMxDoc.ActiveView
  
  If TypeOf pActiveView Is IMap Then
    Call m_ActiveViewChanged_ContentsChanged
  End If
  
End Function
Private Sub m_ActiveViewChanged_ContentsChanged()

'The If statement is required because this code first runs before the MXD has opened fully, so
'the CommandBars method cannot be called yet.

Dim pLayoutToolBar As ICommandBar

  If m_runYet Then
    Set pLayoutToolBar = Application.Document.CommandBars.Find(PageLayout_LayoutToolbar)
    pLayoutToolBar.Dock esriDockHide
  End If
  m_runYet = True
  
End Sub

